package com.pfzy.frescodemo

import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import com.facebook.drawee.view.SimpleDraweeView

class MainActivity : AppCompatActivity(), View.OnClickListener {
    var simpleDraweeView: SimpleDraweeView? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        simpleDraweeView = findViewById(R.id.drawee_view)
        findViewById<Button>(R.id.btn_load_image).setOnClickListener(this)
    }

    override fun onClick(v: View) {
        when (v.id) {
            R.id.btn_load_image -> loadImage()
        }
    }

    private fun loadImage() {
        val url = "https://github.com/guoxiaoxing/android-open-framwork-analysis/raw/master/art/fresco/scenery.jpg"
        simpleDraweeView?.setImageURI(Uri.parse(url))
    }
}